{% extends 'indexTemplate.html' %}

{% load staticfiles %}

{% block title %}讲师详情 - 慕学在线网{% endblock %}

{% block customBread %}
<section>
    <div class="wp">
        <ul  class="crumbs">
            <li><a href="{% url 'index' %}">首页</a>></li>
            <li><a href="{% url 'orgs:teacherPage' %}">授课讲师</a>></li>
            <li>讲师详情</li>
        </ul>
    </div>
</section>
{% endblock %}

{% block content %}
<section>
	<div class="wp butler-detail-box butler-diaryd-box clearfix">
        <div class="fl list">
            <div class="butler_detail_list clearfix">
                <div class="brief">
                    <dl class="des">
                        <dt>
                            <div class="picpic">
                                <img width="100" height="100" src="{{ MEDIA_URL }}{{ teacher.images }}"/>
                            </div>
                            <div class="btn">
                                <span class="fl btn1 collectionbtn" id="jsLeftBtn">
                                    {% if hasFavTeacher %}取消收藏{% else %}收藏{% endif %}
                                </span>
                                <span class="fr btn2 shareBtn bdsharebuttonbox"
                                      data-text="授课教师-李老师-慕学网"
                                      data-desc="我在#慕课网#发现了"
                                      data-comment="李老师，工作年限：5年；学历：本科；所在公司：阿里巴巴&nbsp;；经典案例：django入门和深入；flask入门"
                                      data-url="/diary/hk_detail/10/">
                                    <span class="fl">分享</span>
                                    <a href="#" class="bds_more" data-cmd="more"></a>
                                </span>
                            </div>
                        </dt>
                        <dd>
                            <a href="/diary/hk_detail/10/">
                                <h1>{{ teacher.name }}<span class="key picbig">金牌讲师</span></h1>
                            </a>
                            <ul class="cont">
                                <li>工作年限：<span>{{ teacher.workYear }}年</span></li>
                                <li>就职公司：<span>{{ teacher.workCompany }}</span></li>
                                <li>工作职位：<span>{{ teacher.workPosition }}</span></li>
                                <li>教学特点：<span>{{ teacher.points }}</span></li>
                            </ul>
                        </dd>
                    </dl>
                </div>
            </div>
            <div class="butler_detail_cont clearfix">
                <div class="left layout">
				<div class="head">
					<ul class="tab_header">
						<li class="active"><a href="/diary/hk_detail/10/">全部课程</a> </li>
					</ul>
				</div>
                    <div class="companycenter">
                        <div class="group_list brief">
                        {% for teacherCourse in teacher.getTeacherCourses %}
                            <div class="module1_5 box">
                                <a href="{% url 'courses:courseDetail' teacherCourse.id %}">
                                    <img width="214" height="190" class="scrollLoading" src="{{ MEDIA_URL }}{{ teacherCourse.images }}"/>
                                </a>
                                <div class="des">
                                    <a href="{% url 'courses:courseDetail' teacherCourse.id %}"><h2>{{ teacherCourse.name }}</h2></a>
                                    <span class="fl">时长：<i class="key">{{ teacherCourse.learnTimes }}</i></span>
                                    <span class="fr">学习人数：{{ teacherCourse.students }}</span>
                                </div>
                                <div class="bottom">
                                    <span class="fl">{{ teacherCourse.Org.name }}</span>
                                    <span class="star fr  notlogin" data-favid="15">{{ teacherCourse.Org.favNum }}</span>
                                </div>
                            </div>
                        {% endfor %}
                        </div>
                    </div>
            </div>
            </div>
        </div>
        <div class="fr list">
             <div class="butler_detail_list">
                <div class="right butler-company-box">
                <div class="head">
                    <h1>慕课网</h1>
                    <p>知名高校，权威教学</p>
                </div>
                <div class="pic">
                    <a href="{% url 'orgs:orgHome' teacher.org.id %}">
                        <img width="150" height="80" src="{{ MEDIA_URL }}{{ teacher.org.image }}"/>
                    </a>
                </div>
                <a href="{% url 'orgs:orgHome' teacher.org.id %}">
                    <h2 class="center">慕课网</h2>
                </a>
                <p class="center tell">地址：{{ teacher.org.name }}</p>
                <a class="btn" id="jsRightBtn">
                    {% if hasFavOrg %}取消收藏{% else %}收藏{% endif %}
                </a>
            </div>
            </div>
            <div class="butler_detail_cont">
                <div class="butler_list_box">
                    <div class="right layout">
                        <div class="head">讲师排行榜</div>
                        {% for teacherHot in teachersHot %}
                        <dl class="des">
                            <span class="num fl">{{ forloop.counter }}</span>
                            <a href="{% url 'orgs:teacherDetail' teacherHot.id %}">
                                <dt>
                                    <img width="50" height="50" class="scrollLoading" src="{{ MEDIA_URL }}{{ teacherHot.images }}"/>
                                </dt>
                            </a>
                            <dd>
                                <a href="{% url 'orgs:teacherDetail' teacherHot.id %}">
                                    <h1 title="bobby">{{ teacherHot.name }}</h1>
                                </a>
                                <p>工作年限：<span>{{ teacherHot.workYear }}年</span></p>
                            </dd>
                        </dl>
                    {% endfor %}
                    </div>
                </div>
            </div>
        </div>
	</div>
</section>
<script type="text/javascript">
$(function(){
    //收藏讲师:2
    $('#jsLeftBtn').on('click',function(){
        add_fav($(this),{{ teacher.id }},2);
    })
    //收藏机构:1
    $('#jsRightBtn').on('click',function(){
        add_fav($(this),{{ teacher.Org.id }},1);
    })
})
function add_fav(current_elem,favId,favType){
    $.ajax({
        cache: false,
        async: true,
        type: "POST",
        url:"{% url 'operations:userFavorite' %}",
        data:{'favId':favId,'favType':favType},
        beforeSend:function(xhr,settings){
            xhr.setRequestHeader("X-CSRFToken","{{ csrf_token }}");
        },
        success: function(data){
            if(data.status == "success"){
                if(data.msg == "收藏成功"){
                    current_elem.text("取消收藏")
                }else{
                    current_elem.text("收藏")
                }
            }else{
                if(data.msg == "用户未登录"){
                    alert("您还没有登录,请先登录！")
                    window.location.href="{% url 'users:login' %}";
                }else{
                    alert(data.msg)
                }
            }
        }
    })
}
</script>
{% endblock %}


